import React, { Component, useMemo, useState } from "react";
import { View, Image, Text, Button } from "@tarojs/components";
import Taro from "@tarojs/taro";

import styles from "./index.module.scss";
import MiniHeader from "@/components/UI/MiniHeader";

export default function() {
  let [text, setText] = useState("");
  return (
    <View className={styles.page}>
      测试页面,给开发调试使用
      <Button
        onClick={() => {
          Taro.login().then(res => {
            setText(res.code);
          });
        }}
      >
        获取code
      </Button>
      <Button
        openType={"getUserInfo"}
        onGetUserInfo={e => {
          setText(JSON.stringify(e.detail, null, 2));
        }}
      >
        获取授权
      </Button>
      <Button
        onClick={() => {
          Taro.scanCode({}).then(res => {
            setText(res.result);
          });
        }}
      >
        微信扫码
      </Button>
      <Text>{text}</Text>
      {text && (
        <Button
          onClick={() => {
            Taro.setClipboardData({
              data: text,
            });
          }}
        >
          复制
        </Button>
      )}
    </View>
  );
}
